<?php
  session_start();
  require 'include/configDB.php';
  $id = $_GET['id'];
  $query = mysql_query("SELECT * FROM penugasan_wali WHERE id=$id");
  $data = mysql_fetch_assoc($query);
  $id_kelas = $data['id_kelas'];
  $kelas = mysql_query("SELECT * FROM kelas WHERE id=$id_kelas");
  $kelas_data = mysql_fetch_assoc($kelas);
  //echo $kelas;
  $id_jurusan = $kelas_data['id_jurusan'];

   if (! isset($_SESSION['role']) || ($_SESSION['role'] != "Admin") && ($_SESSION['role'] != "Staff Tata Usaha")) {
  header('Location: login.php');
}
 
  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Penugasan Wali Kelas</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="clockp.js"></script>
<script type="text/javascript" src="clockh.js"></script> 
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="ddaccordion.js"></script>
<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
</script>

<script type="text/javascript" src="jconfirmaction.jquery.js"></script>
<script type="text/javascript">
	
	 function validasi(){
    if (document.edit_penugasan.tahun_ajaran.value == "NULL") {
      alert("Tahun ajaran harus diisi");
      return false;

    }

    if (document.edit_penugasan.NIK.value == "NULL") {
      alert("Nama guru harus diisi");
      return false;
    }

    if (document.edit_penugasan.tingkat.value == "NULL") {
      alert("tingkat harus diisi");
      return false;
    }

    if (document.edit_penugasan.id_jurusan.value == "NULL") {
      alert("tingkat harus diisi");
      return false;
    }

    if (document.edit_penugasan.no_kelas.value == "NULL") {
      alert("tingkat harus diisi");
      return false;
    }
  }
	
</script>

<script language="javascript" type="text/javascript" src="niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css" />
<style>
      <?php include 'include_style.php'; ?>
</style>
</head>
<body>
<div id="main_container">

	   <?php include 'header.php'; ?>
    
    <div class="main_content">
                
                    
    <div class="center_content">  
		
    
	
    <div class="left_content">
    
    		<?php include 'left_content.php'; ?>
        <?php include 'calendar.php' ; ?>

    </div>  
    
    <div class="right_content">
		<h2>Edit Penugasan Wali Kelas</h2>
     	<div id="stylized" class="myform">
         	<form id="edit_penugasan" name="edit_penugasan" method="post" action="include/edit_penugasan_wali.php" onsubmit='return validasi();'>
            <input type="hidden" value="<?php echo $id?>" name="id">
        		<h1>Penugasan Perwalian</h1>
      			<table>
                <tr>
                    <td>
                      <label>Tahun Ajaran
                        <span class="small">Isi tahun ajaran</span>
                      </label>
                    </td>
                    <td>
                      :
                    </td>
                    <td>
                      <select name="tahun_ajaran" id="tahun_ajaran">
                        <option value="NULL">---------Pilih----------</option>
                          <?php 
                            $tahun_ajaran = mysql_query("SELECT * FROM tahun_ajaran");  
                            while($tahun_ajaran_data = mysql_fetch_assoc($tahun_ajaran))
                              {
                              ?>  
                                <option value="<?= $tahun_ajaran_data['id']; ?>" <?php echo ($data['id_tahun_ajaran'] == $tahun_ajaran_data['id']) ? "selected" : "";?>><?= $tahun_ajaran_data['tahun_ajaran']?></option>  
                              <?php  
                                }  
                              ?>    
                        </select>
                      </td>
                  </tr>
                  <tr>
                      <td>
                        <label>Nama Guru
                          <span class="small">Nama Lengkap Guru</span>
                        </label>
                      </td>
                      <td>
                      :
                    </td>
                        <td>
                           <select name="NIK">
                              <?php 
                                  $nama_guru = mysql_query("SELECT * FROM guru");  
                                  while($guru_data = mysql_fetch_assoc($nama_guru))
                                  {
                                  ?>  
                                <option value="<?= $guru_data['NIK']; ?>" <?php echo ($data['NIK'] == $guru_data['NIK']) ? "selected" : "";?>><?= $guru_data['nama']?></option>-->  
                                <?php  
                                }  
                                ?>    
                          </select>
                        </td>
                  </tr>
                  <tr>
                      <td>
                        <label>Kelas<span class="small">isi kelas(tingkat kelas, jurusan, nomor kelas)</span></label>
                      </td>
                      <td>
                      :
                    </td>
                      <td>
                          <select name="tingkat">
                            <option value="10" <?php echo ($kelas_data['tingkat'] == "10") ? "selected" : ""; ?>>10</option>
                            <option value="11"  <?php echo ($kelas_data['tingkat'] == "11") ? "selected" : ""; ?> >11</option>
                            <option value="12"  <?php echo ($kelas_data['tingkat'] == "12") ? "selected" : ""; ?> >12</option>      
                          </select>
                    <select name="id_jurusan">
                         <?php
                            $jurusan_query = mysql_query("SELECT * FROM jurusan");
                            while ($jurusan_data = mysql_fetch_assoc($jurusan_query)) 
                            {
                              ?>

                                <option value="<?= $jurusan_data['id']; ?>" <?php echo ($kelas_data['id_jurusan'] == $jurusan_data['id']) ? "selected" : "";?>><?= $jurusan_data['nama']?></option>-->  
                                <?php  
                            }
                         ?>
                      </select>
                      <select name="no_kelas">
                        <option value="1" <?php echo ($kelas_data['nomor'] == "1") ? "selected" : ""; ?>>1</option>
                        <option value="2" <?php echo ($kelas_data['nomor'] == "2") ? "selected" : ""; ?>>2</option>
                        <option value="3" <?php echo ($kelas_data['nomor'] == "3") ? "selected" : ""; ?>>3</option>
                        <option value="4" <?php echo ($kelas_data['nomor'] == "4") ? "selected" : ""; ?>>4</option>
                        <option value="5" <?php echo ($kelas_data['nomor'] == "5") ? "selected" : ""; ?>>5</option>
                      </select>
                    </td>
                  </tr>
                  <td><input type="submit" name="submit" class="menuitem_red" value="Simpan"/></td>
                </tr>   
          </table>
          <div class="spacer"></div>
          
          </form>
		</div>
    </div><!-- end of right content-->
            
                    
	</div>   <!--end of center content -->               
                    
                    
    
    
    <div class="clear"></div>
    </div> <!--end of main content-->
	
    
    <div class="footer">
          <?php include 'footer.php'; ?>

    	
    </div>

</div>		
</body>
</html>